﻿using Practice.IRepository;
using Practice.PH4_2104A.DAL;
using Practice.PH4_2104A.Shopping.SevenLayerFramework.Domin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Practice.Repository
{
    /// <summary>
    /// 分类的仓储实现
    /// </summary>
    public class CategoryRepository : ICategoryRepository
    {
        MyDbContext _context;

        public CategoryRepository(MyDbContext context)
        {
            _context = context;
        }

        //删除
        public void Delete(CategoryModel model)
        {
            _context.Categories.Remove(model);
        }

        //查询
        public IQueryable<CategoryModel> GetAll()
        {
            return _context.Categories;
        }

        //添加
        public void Insert(CategoryModel model)
        {
            _context.Categories.Add(model);
        }

        //修改
        public void Update(CategoryModel model)
        {
            _context.Categories.Update(model);
        }
    }
}
